package com.jokelandave.poc.server.domain;

import java.util.Date;
import javax.persistence.Id;

import com.googlecode.objectify.Key;

public class SportEvent{
	
	@Id
	Long id;
	
	Key<Team> homeTeam;
	
	Key<Team> awayTeam;
	
	String location;
	
	Date eventStartTime;
	
	int line;
	
	Key<Team> favorite;
	
	public SportEvent(Key<Team> homeTeam, Key<Team> awayTeam, String location, Date eventStartTime, Key<Team> favorite, int line)
	{
		this.homeTeam = homeTeam;
		this.awayTeam = awayTeam;
		this.location = location;
		this.eventStartTime = eventStartTime;
		this.line = line;
		this.favorite = favorite;
	}
	
	public SportEvent()
	{
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((awayTeam == null) ? 0 : awayTeam.hashCode());
		result = prime * result
				+ ((eventStartTime == null) ? 0 : eventStartTime.hashCode());
		result = prime * result
				+ ((favorite == null) ? 0 : favorite.hashCode());
		result = prime * result
				+ ((homeTeam == null) ? 0 : homeTeam.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + line;
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SportEvent other = (SportEvent) obj;
		if (awayTeam == null) {
			if (other.awayTeam != null)
				return false;
		} else if (!awayTeam.equals(other.awayTeam))
			return false;
		if (eventStartTime == null) {
			if (other.eventStartTime != null)
				return false;
		} else if (!eventStartTime.equals(other.eventStartTime))
			return false;
		if (favorite == null) {
			if (other.favorite != null)
				return false;
		} else if (!favorite.equals(other.favorite))
			return false;
		if (homeTeam == null) {
			if (other.homeTeam != null)
				return false;
		} else if (!homeTeam.equals(other.homeTeam))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (line != other.line)
			return false;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		return true;
	}
	
	public Key<SportEvent> getKey()
	{
		return Key.create(this.getClass(), id);
	}
	public Long getId()
	{
		return id;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public Date getEventStartTime() {
		return eventStartTime;
	}

	public void setEventStartTime(Date eventStartTime) {
		this.eventStartTime = eventStartTime;
	}

	public int getLine() {
		return line;
	}

	public void setLine(int line) {
		this.line = line;
	}

	public Key<Team> getHomeTeam() {
		return homeTeam;
	}

	public void setHomeTeam(Key<Team> homeTeam) {
		this.homeTeam = homeTeam;
	}

	public Key<Team> getAwayTeam() {
		return awayTeam;
	}

	public void setAwayTeam(Key<Team> awayTeam) {
		this.awayTeam = awayTeam;
	}

	public Key<Team> getFavorite() {
		return favorite;
	}

	public void setFavorite(Key<Team> favorite) {
		this.favorite = favorite;
	}
}
